package com.zy.edu.bean;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: HuangHaiShui
 * @Date: 2018/10/6 14:59
 * @Description: 最后的返回结果集
 * 200  :成功
 * 500  :失败
 * 501  :失效token
 */
public class ResponseInfo {

    public static Map<String, Object> success(Object data) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("code", 200);
        resultMap.put("data", data);
        return resultMap;
    }
    //返回数据以及统计结果
    public static Map<String, Object> success(Object data,Object stats) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("code", 200);
        resultMap.put("data", data);
        resultMap.put("stats", stats);
        return resultMap;
    }
    public static Map<String, Object> error(String msg) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("code", 500);
        resultMap.put("message", msg);
        return resultMap;
    }
//    //用于前后端分离，多传一个token
//    public static Map<String, Object> sucOauth(String role, String token) {
//        Map<String, Object> resultMap = new HashMap<String, Object>();
//        resultMap.put("code", 200);
//        resultMap.put("role", role);
//        resultMap.put("token", token);
//        return resultMap;
//    }
    public static Map<String, Object> failOauth() {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("code", 501);
        resultMap.put("message", "鉴权失败");
        return resultMap;
    }
    public static Map<String, Object> userExisted() {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("code", 502);
        resultMap.put("message", "已有用户在其他地方登录");
        return resultMap;
    }




}
